<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/common/include.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<title>分配角色</title>
	<jsp:include page="../../../common/head.jsp">
		 <jsp:param name="_spPage" value="true"/>
	</jsp:include>
	<script language="javascript">
	
	
	//为角色添加用户
	function addUser()
	{
		var userIds = '${userIds}';
		var users=ModalWindow("jump.do?path=${ctx}/jsp/common/user/index.jsp&userIds="+userIds,1000,600);
		if(users!=null)
		{
			//用户信息格式：userId,userName;...
			if(confirm("确认向角色内添加所选用户"))
				window.location.href = 'insUserOperationRole.do?users='+users+'&roleId=${roleId}';    
		}
	}
	//为角色删除指定的对应用户
	function deleteUser()
	{
		var users=document.getElementsByName("user1");
		var str = xjCommon.getValueStr("user1",",");
		if(str!=null && str.length>0){
			if(confirm("确定要删除该角色关联的用户吗！")){
				var a=ModalWindow('jump.do?path=delUserOperationRole.do&users='+str+'&roleId=${roleId}',800,600);    
				if(a=="ok")
					xjSpPage.spPageSubmit();
			}
		}
		else
			alert("请选择要移除的用户!");
	}
</script>
</head>
<body>
	<form name="UserListForm" method="post" action="listUserOperationRole.do?roleId=${roleId}&roleName=${roleName}" id="UserListForm">
	<div id="body_div">
	<w:ShowTitle name="分配角色">
	<w:TitleButton funcName="查询" onClickFunction="_queryDivBg(this)" urlImg="${ctx}/images/main/query.png"/>
	<w:TitleButton funcName="添加用户" onClickFunction="addUser('','${roleId}','${roleName}')" urlImg="${ctx}/images/main/add.png"/>
	<w:TitleButton funcName="移除用户" onClickFunction="deleteUser('${roleId}','${roleName}')" urlImg="${ctx}/images/main/delete.png"/>
	</w:ShowTitle>
	<div id="body_content">
		<div id="queryDiv">
			<table>
				<tr>
				  <td>用户ID</td>
				  <td class="left_align">
				    <input name="userId" type="text" id="userId" value="${userId}"/>
				    <input type="hidden" name="funcGoupId" value="${roleId }"/>
				  </td>
				  <td>用户姓名</td>
				  <td class="left_align">
				    <input name="userName" type="text" id="userlist.userName" value="${userName}"/>
				  </td>
			  	</tr>
				<tr>
					<td colspan="4">
						<input type="submit" name="button" class="btn_standard" value="　查 询　" />
						<input name="button" type="button" class="btn_standard" onclick="_cancelQuery()" value="取消" />
					</td>
				</tr>
		</table>
		</div>
           <table width="100%" border="0" cellpadding="0" cellspacing="1"
				class="tableBorder">
           	<tr>
               	<td width="40" class="td_title"><span onclick="xjCommon.checkAll('user1')">全选</span></td>
                <td width="120" class="td_title">用户ID</td>
                <td width="150" class="td_title">用户名</td>
                <td class="td_title">办公电话</td>
                <td class="td_title">电子邮件</td>
             </tr>
			<c:forEach items="${list}" var="obj" varStatus="indx">
               <tr>
               	<td><input type="checkbox" name="user1"  value="${obj.userId}" id="user1"/></td>
                   <td>${obj.userId}</td>
                   <td>${obj.userName}</td>
                   <td>${obj.officeTel}</td>
                   <td>${obj.email}</td>
               </tr>
               </c:forEach>
          </table>
          <w:spPage/>
          </div>
          </div>
	</form>
</body>
</html>
